cmake_minimum_required(VERSION 3.5)
project(robot_grpc_server)

# Sets compile object to debug mode
set(CMAKE_BUILD_TYPE Debug)

include(./common.cmake)

# Finds packages
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(Protobuf REQUIRED)
find_package(gRPC CONFIG REQUIRED)
find_package(robot_grpc_proto REQUIRED)
find_package(jsoncpp REQUIRED)
find_package(robot_interface REQUIRED)

# Sets library path
link_directories(${CMAKE_INSTALL_PREFIX}/../robot_grpc_proto/lib)

# Includes header files
include_directories(
  ${CMAKE_INSTALL_PREFIX}/../robot_grpc_proto/include/
)

INCLUDE_DIRECTORIES(
  ${CMAKE_CURRENT_SOURCE_DIR}/include/robot_grpc_server/
)

include_directories(/usr/include/jsoncpp)

# Adds grpc server node
add_executable(robot_grpc_server src/robot_grpc_server_node.cpp
                                 src/robot_grpc_server.cpp
                                 src/stream_data_reactor.cpp)
target_link_libraries(robot_grpc_server 
robot_grpc_proto
absl::check
absl::flags
absl::flags_parse
absl::log
jsoncpp
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF})
ament_target_dependencies(robot_grpc_server
  rclcpp
  std_msgs
  sensor_msgs
  tf2
  tf2_ros
  jsoncpp
  robot_grpc_proto
  robot_interface
)


# Installs grpc server file
install(TARGETS
robot_grpc_server
  DESTINATION lib/${PROJECT_NAME})


ament_package()
